import java.io.*;
import java.util.Scanner;

/*
 ID: ning yusui
 LANG: JAVA
 TASK: ttwo
 */

public class ttwo {
    public static final int GRID_SIZE = 10;
    public static final int GRID_POSITION_SIZE = GRID_SIZE * GRID_SIZE;
    public static final int MOVE_STATE_SIZE = GRID_POSITION_SIZE * 4;
    Scanner in;
    PrintWriter out;
    MoveAbleObject farmer;
    MoveAbleObject cow;
    static char[][] grid;
    boolean visited[] = new boolean[MOVE_STATE_SIZE * MOVE_STATE_SIZE];

    boolean isVisited() {
        int hashCode = calcHashCode();
        return visited[hashCode];
    }

    void setVisited() {
        int hashCode = calcHashCode();
        visited[hashCode] = true;
    }

    private int calcHashCode() {
        return farmer.calcHashCode() * MOVE_STATE_SIZE + cow.calcHashCode();
    }

    public ttwo() throws IOException {
        in = new Scanner(new File(this.getClass().getName() + ".in"));
        out = new PrintWriter(new BufferedWriter(new FileWriter(this.getClass().getName() +
                ".out")));
    }

    private void work() {
        input();
        int ans = moveToMeet();
        out.println(ans);
        out.flush();
        out.close();
    }

    private void input() {
        grid = new char[GRID_SIZE][GRID_SIZE];
        for (int i = 0; i < GRID_SIZE; i++) {
            grid[i] = in.next().toCharArray();
            for (int j = 0; j < grid[i].length; j++) {
                if (grid[i][j] == 'F') {
                    farmer = new MoveAbleObject(i, j, 0);
                    grid[i][j] = '.';
                } else if (grid[i][j] == 'C') {
                    cow = new MoveAbleObject(i, j, 0);
                    grid[i][j] = '.';

                }
            }
        }
    }

    int moveToMeet() {
        for (int i = 0; !isVisited(); i++) {
            if (farmer.position.calcHashCode() == cow.position.calcHashCode()) {
                return i;
            }
            setVisited();
            farmer.move();
            System.out.println(i + " farmer move to: " + farmer.position.row + "," + farmer.position.col + "," + farmer.direct);
            cow.move();
            System.out.println(i + " cow move to: " + cow.position.row + "," + cow.position.col + "," + cow.direct);
        }
        return 0;
    }

    public static void main(String[] args) throws IOException {
        new ttwo().work();
    }

    static class MoveAbleObject {
        protected static final int moveDist[][] = {
                {-1, 0}, //N
                {0, 1},  //E
                {1, 0},  //S
                {0, -1}, //W
        };

        int direct;
        Position position;

        MoveAbleObject(int row, int col, int direct) {
            position = new Position(row, col);
            this.direct = direct;
        }

        void move() {
            Position nextPosition = new Position(position.row + moveDist[direct][0], position.col + moveDist[direct][1]);
            if (nextPosition.isValid()) {
                position = nextPosition;
            } else {
                direct = (direct + 1) % moveDist.length;
            }
        }

        int calcHashCode() {
            int result = direct * GRID_POSITION_SIZE + position.calcHashCode();
            return result;
        }
    }

    static class Position {
        int row;
        int col;

        Position(int row, int col) {
            this.row = row;
            this.col = col;
        }

        public boolean isValid() {
            return col >= 0 && col < GRID_SIZE && row >= 0 && row < GRID_SIZE
                    && grid[row][col] != '*';
        }

        public int calcHashCode() {
            int result = row * GRID_SIZE + col;
            return result;
        }
    }
}
